package com.topnav.mc.admin.security.jwt;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 说明：
 * @类名: JwtUser
 * <p>
 *
 * </p>
 * @author   kenny
 * @Date	 2022年2月10日上午11:40:38
 */
@Data
public class JwtUser implements UserDetails {
	/** 用户名 */
    private String username;
    /** 密码 */
    private String password;
    /** 权限（角色）列表 */
    Collection<? extends GrantedAuthority> authorities;

    public JwtUser(String userCode, String password, List<GrantedAuthority> grantedAuthorities) {
        this.username = userCode;
        this.password = password;
        this.authorities = grantedAuthorities;
    }
    
   
	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}

	@Override
	public String getPassword() {
		return password;
	}

	@Override
	public String getUsername() {
		return username;
	}

	@Override
	public boolean isAccountNonExpired() {
		/** false 帐号已过期， true 未过期*/
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		/** false 帐号已锁定， true 未锁定*/
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		/** false 凭证过期， true 未过期*/
		return true;
	}

	@Override
	public boolean isEnabled() {
		/** false 禁用， true 在用*/
		return true;
	}

}
